function layout(root, canvasDom, config) {
  if (!root) {
    console.error('请输入dom节点')
    return
  }
  if (typeof root === 'string') {
    root = document.querySelector(root)
  }
  return new Promise(function (resolve, reject) {
    loadImgs(function () {
      const renderList = new LayoutTree(root)
      const layoutWidth = root.offsetWidth
      const layoutHeight = root.offsetHeight
  
      const canvas = new Canvas(canvasDom,layoutWidth, layoutHeight)
      new Render(renderList, canvas.ctx)
      resolve(canvas)
    })
  })
}
